<?php
if ($_SESSION['login_user']['status'] != 'admin' || LZ_MODULE != 'admin') die('Access Denied');
$m = $_GET['m'];

if ($m == 'rebuild_photo_search_index')
{
	include_once('model/photo.php');
	$photo = new LZ_Photo;
	include_once('model/search.php');
	$search = new LZ_Search;
	$photos = $photo->get_list();
	$total = 0;
	foreach($photos as $p)
	{
		$search->add('photo',$p['photo_id'],$p['tag'].' '.$p['title']);
		$total++;
	}
	$view_data['success_msg'] = REBUILT.$total;
}
else if ($m == 'update_image_size')
{
	include_once('model/photo.php');
	$photo = new LZ_Photo;
	$photos = $photo->get_list();
	$total = 0;
	foreach($photos as $p)
	{
		if (!$p['orig_size'])
		{
			$imgarr = getimagesize($p['file_path']);
			$orig_size = $imgarr[0].'x'.$imgarr[1];
			$photo->update($p['photo_id'],array('orig_size'=>$orig_size));
		}
		$total++;
	}
	$view_data['success_msg'] = UPDATE_DONE.$total;
}
?>